﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.Utils.Menu;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.DXErrorProvider;
using DevExpress.XtraEditors.Repository;

namespace QuanLyThuNgan
{
    public partial class frm_DM_DichVu : DevExpress.XtraEditors.XtraForm
    {
        public frm_DM_DichVu()
        {
            InitializeComponent();
        }

        string sTenSearch = "";
        string sColSearch;

        public static string sIDSearch="";
        public static string sTenValueSearch="";
        string sTenTam, sColTam;
        int iRowIndex;
        //call attribute -------------------------------------------
        DichVuCTL dichVuCtl = new DichVuCTL();
        DichVuDTO dichVuDto = new DichVuDTO();
        DMLoaiDichVuCTL loaidvCtl= new DMLoaiDichVuCTL();
        DMNhomVSGPBCTL nhomVSGPBCtl = new DMNhomVSGPBCTL();
        DMNoiGuiDichVuCTL noiGuiDVCtl = new DMNoiGuiDichVuCTL();
        private DatasetStatus m_Status = DatasetStatus.None;

        #region "enum"
        enum DatasetStatus
        {
            Add = 1,
            Edit = 2,
            None = 0
        }
        #endregion

        private void frm_DM_DichVu_Load(object sender, EventArgs e)
        {
            //load loai dich vu----------------------------------------------
            //int iLoaiDV = Uit.it_Parse.ToInteger(gdLoaiDichVu.EditValue);
            DataTable dtLoaiDV = loaidvCtl.m_SelectDMLoaiDV();
            ClassHelp.m_gridLookUpEdit(dtLoaiDV, gdLoaiDichVu, "TenLoaiDVu", "loaidvu");
            //gdLoaiDichVu.Properties.View.Columns["loaidvu"].Visible = false;
            //load nhom VSGPB----------------------------------
            DataTable dtNhomVSGPB = nhomVSGPBCtl.m_SelectDMNhomVSGPB();
            ClassHelp.m_gridLookUpEdit(dtNhomVSGPB, gdNhomVSGPB, "TenNhomVSGPB", "IDNhomVSGPB");
            //gdNhomVSGPB.Properties.View.Columns["IDNhomVSGPB"].Visible = false;

            //load noi gui dich vu------------------------------------------
            DataTable dtNoiGuiDV = noiGuiDVCtl.m_SelectDMNoiGuiDV();
            ClassHelp.m_gridLookUpEdit(dtNoiGuiDV, gdNoiGui, "TenNoiGuiDichVu", "IDNoiGuiDichVu");
            //gdNoiGui.Properties.View.Columns["IDNoiGuiDichVu"].Visible = false;

            //load phan loai dich vu---------------------------------------
            DataTable dtPhanLoaiDV = loaidvCtl.m_SelectDMLoaiDV();
            ClassHelp.m_gridLookUpEdit(dtPhanLoaiDV, gdPhanLoaiDV, "TenLoaiDVu", "loaidvu");
            //gdPhanLoaiDV.Properties.View.Columns["loaidvu"].Visible = false;
            
            //load nhom dich vu----------------------------------------------
            DataTable dtloadNhomDV = dichVuCtl.m_SelectNhomDV();
            ClassHelp.m_CheckComboboxEdit(dtloadNhomDV, chkNhomDV, "TenDichVu", "dvucode");

            //load dich vu----------------------------------------------------------------
            DataTable dtDV = dichVuCtl.m_SelectAllDV();
            gdDichVu.DataSource = dtDV;

            //set button condition------------------------
            m_setReadOnly();
            btnInsert.Enabled = true;
            btnUpdate.Enabled = true;
            btnDelete.Enabled = true;
            btnSave.Enabled = false;

        }


        #region "Condition"

        private void txtDichVuCode_KeyPress(object sender, KeyPressEventArgs e)
        {
           // e.KeyChar = Convert.ToChar(e.KeyChar.ToString().ToUpper());
        }

        private void txtTenDichVu_KeyPress(object sender, KeyPressEventArgs e)
        {
            //e.KeyChar = Convert.ToChar(e.KeyChar.ToString().ToUpper());
        }

        private void txtMaBHYT_KeyPress(object sender, KeyPressEventArgs e)
        {
            //e.KeyChar = Convert.ToChar(e.KeyChar.ToString().ToUpper());
        }

        private void txtGia_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
            {
                XtraMessageBox.Show("Chỉ nhập kí tự số và không được nhập ký tự chữ cái");
                e.Handled = true;
            }
        }

        private void txtGiaBHYT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar) )
            {
                XtraMessageBox.Show("Chỉ nhập kí tự số và không được nhập ký tự chữ cái");
                e.Handled = true;
            }
        }

        private void txtDichVuCode_Leave(object sender, EventArgs e)
        {
           
            //for (int i = 0; i < gvDichVu.RowCount; i++)
            //{
            //    DataRow drpt = gvDichVu.GetDataRow(i);
            //    if (drpt["dvucode"].ToString().ToUpper().Trim() == txtDichVuCode.Text.ToString().Trim() || drpt["dvucode"].ToString().ToLower().Trim() == txtDichVuCode.Text.ToString().Trim())
            //    {

            //        XtraMessageBox.Show("Trùng mã dịch vụ code");
            //        dxErrorProvider1.SetError(txtDichVuCode, "Trùng mã dịch vụ code");
            //        txtDichVuCode.Focus();
            //        return;
            //    }
                
            //    else
            //        if (txtDichVuCode.Text.ToString()=="")
            //        {
            //            break;
            //        }
            //}

        }

        private void txtTenDichVu_Leave(object sender, EventArgs e)
        {
            //for (int i = 0; i < gvDichVu.RowCount; i++)
            //{
            //    DataRow drpt = gvDichVu.GetDataRow(i);
            //    if (drpt["TenDichVu"].ToString().ToUpper().Trim() == txtTenDichVu.Text.ToString().Trim() || drpt["TenDichVu"].ToString().ToLower().Trim() == txtTenDichVu.Text.ToString().Trim())
            //    {

            //        XtraMessageBox.Show("Trùng tên dịch vụ");
            //        dxErrorProvider1.SetError(txtTenDichVu, "Trùng tên dịch vụ");
            //        txtTenDichVu.Focus();
            //        return;
            //    }
            //    else
            //        if (txtTenDichVu.Text.ToString()=="")
            //        {
            //            break;
            //        }
            //}
        }


        //lay ten can tim----------------------------------------------------------------
        private void gvDichVu_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            sTenSearch = e.Value.ToString();
            sColSearch = e.Column.FieldName;
        }

        //set ten can tim-----------------------------------------------------
        private void gvDichVu_ColumnFilterChanged(object sender, EventArgs e)
        {
            ColumnView view = gvDichVu;
            view.ActiveFilter.Add(view.Columns[sColSearch], new ColumnFilterInfo("[" + sColSearch + "] Like '%" + sTenSearch + "%'", ""));

        }

        //Ap dung tab toi gia tri khac------------------------------
        private void gdLoaiDichVu_Enter(object sender, EventArgs e)
        {
            SendKeys.Send("{F4}");
        }

        private void chkNhomDV_Enter(object sender, EventArgs e)
        {
            SendKeys.Send("{F4}");
        }

        private void gdPhanLoaiDV_Enter(object sender, EventArgs e)
        {
            SendKeys.Send("{F4}");
        }

        private void gdNhomVSGPB_Enter(object sender, EventArgs e)
        {
            SendKeys.Send("{F4}");
        }

        private void gdNoiGui_Enter(object sender, EventArgs e)
        {
            SendKeys.Send("{F4}");
        }

        //search loai dich vu---------------------------------------------------------------------
        private void gdLoaiDichVu_EditValueChanged(object sender, EventArgs e)
        {
            if (gdLoaiDichVu.EditValue != null)
            {
                sIDSearch = gdLoaiDichVu.EditValue.ToString();
                sTenValueSearch = gdLoaiDichVu.Text;
                dxErrorProvider1.SetError(gdLoaiDichVu, "");
            }
        }

        private void gridLookUpEdit1View_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            sTenTam = e.Value.ToString();
            sColTam = e.Column.FieldName;
        }

        private void gridLookUpEdit1View_ColumnFilterChanged(object sender, EventArgs e)
        {
            ColumnView view = gdLoaiDichVu.Properties.View;
            view.ActiveFilter.Add(view.Columns[sColTam],
              new ColumnFilterInfo("[" + sColTam + "] Like '%" + sTenTam + "%'", ""));
        }

        //search phan loai dich vu----------------------------------------------
        private void gdPhanLoaiDV_EditValueChanged(object sender, EventArgs e)
        {
            if (gdPhanLoaiDV.EditValue != null)
            {
                sIDSearch = gdPhanLoaiDV.EditValue.ToString();
                sTenValueSearch = gdPhanLoaiDV.Text;
                dxErrorProvider1.SetError(gdPhanLoaiDV, "");
            }

        }

        private void gridView1_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            sTenTam = e.Value.ToString();
            sColTam = e.Column.FieldName;
        }

        private void gridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            ColumnView view = gdPhanLoaiDV.Properties.View;
            view.ActiveFilter.Add(view.Columns[sColTam],
              new ColumnFilterInfo("[" + sColTam + "] Like '%" + sTenTam + "%'", ""));
        }


        //search nhom VSGPB------------------------------------------------------
        private void gdNhomVSGPB_EditValueChanged(object sender, EventArgs e)
        {
            if (gdNhomVSGPB.EditValue != null)
            {
                sIDSearch = gdNhomVSGPB.EditValue.ToString();
                sTenValueSearch = gdNhomVSGPB.Text;
            }

        }

        private void gridView3_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            sTenTam = e.Value.ToString();
            sColTam = e.Column.FieldName;
        }

        private void gridView3_ColumnFilterChanged(object sender, EventArgs e)
        {
            ColumnView view = gdNhomVSGPB.Properties.View;
            view.ActiveFilter.Add(view.Columns[sColTam],
              new ColumnFilterInfo("[" + sColTam + "] Like '%" + sTenTam + "%'", ""));
        }

        //search noi gui----------------------------------------------------
        private void gdNoiGui_EditValueChanged(object sender, EventArgs e)
        {
            if (gdNoiGui.EditValue != null)
            {
                sIDSearch = gdNoiGui.EditValue.ToString();
                sTenValueSearch = gdNoiGui.Text;
            }

        }

        private void gridView2_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            sTenTam = e.Value.ToString();
            sColTam = e.Column.FieldName;
        }

        private void gridView2_ColumnFilterChanged(object sender, EventArgs e)
        {
            ColumnView view = gdNoiGui.Properties.View;
            view.ActiveFilter.Add(view.Columns[sColTam],
              new ColumnFilterInfo("[" + sColTam + "] Like '%" + sTenTam + "%'", ""));
        }

        private void txtDichVuCode_EditValueChanged(object sender, EventArgs e)
        {
            if (txtDichVuCode.Text.ToString() != "")
            {
                dxErrorProvider1.SetError(txtDichVuCode, "");
            }
        }

        private void txtTenDichVu_EditValueChanged(object sender, EventArgs e)
        {
            if (txtTenDichVu.Text.ToString() != "")
            {
                dxErrorProvider1.SetError(txtTenDichVu, "");
            }
        }

        private void txtGia_EditValueChanged(object sender, EventArgs e)
        {
            if (txtGia.Text.ToString() != "")
            {
                dxErrorProvider1.SetError(txtGia, "");
            }
        }

        private void txtGiaBHYT_EditValueChanged(object sender, EventArgs e)
        {
            if (txtGiaBHYT.Text.ToString() != "")
            {
                dxErrorProvider1.SetError(txtGiaBHYT, "");
            }
        }


        bool m_CheckSave()
        {
            bool bCheckValue = true;
            if (txtDichVuCode.Text.ToString() == "")
            {
                dxErrorProvider1.SetError(txtDichVuCode, "Phải nhập dịch vụ code");
                txtDichVuCode.Focus();
                bCheckValue = false;
            }

            if (txtTenDichVu.Text.ToString() == "")
            {
                dxErrorProvider1.SetError(txtTenDichVu, "Phải nhập tên dịch vụ");
                txtTenDichVu.Focus();
                bCheckValue = false;
            }

            if (txtGia.Text.ToString().Trim() == "")
            {
                dxErrorProvider1.SetError(txtGia, "Phải nhập giá dịch vụ");
                txtGia.Focus();
                bCheckValue = false;
            }

            if (Uit.it_Parse.ToString(gdLoaiDichVu.EditValue) == "-1" || Uit.it_Parse.ToString(gdLoaiDichVu.EditValue) == "")
            {
                dxErrorProvider1.SetError(gdLoaiDichVu, "Phải nhập loại dịch vụ");
                //gdLoaiDichVu.Focus();
                bCheckValue = false;
            }

            if (txtGiaBHYT.Text.ToString().Trim() == "")
            {
                dxErrorProvider1.SetError(txtGiaBHYT, "Phải nhập giá BHYT");
                txtGiaBHYT.Focus();
                bCheckValue = false;
            }

            if (Uit.it_Parse.ToString(gdPhanLoaiDV.EditValue) == "-1" || Uit.it_Parse.ToString(gdPhanLoaiDV.EditValue) == "")
            {
                dxErrorProvider1.SetError(gdPhanLoaiDV, "Phải nhập phân loại dịch vụ");
                //gdPhanLoaiDV.Focus();
                bCheckValue = false;
            }

            //-------------------------------------------------------------------------
            //set trung dich vu code------------------------------------
            for (int i = 0; i < gvDichVu.RowCount; i++)
            {
                //|| drpt["dvucode"].ToString().ToLower().Trim() == txtDichVuCode.Text.ToString().Trim()
                if (i != iRowIndex)
                {
                    DataRow drpt = gvDichVu.GetDataRow(i);
                    if (drpt["dvucode"].ToString().ToUpper().Trim() == txtDichVuCode.Text.ToString().ToUpper().Trim() )
                    {

                        //XtraMessageBox.Show("Trùng mã dịch vụ code");
                        dxErrorProvider1.SetError(txtDichVuCode, "Trùng mã dịch vụ code");
                        txtDichVuCode.Focus();
                        bCheckValue = false;
                    }

                    else
                        if (txtDichVuCode.Text.ToString() == "")
                        {
                            break;
                        }
                }
                
            }

            //set trung ten dich vu------------------------------------
            for (int i = 0; i < gvDichVu.RowCount; i++)
            {
                // || drpt["TenDichVu"].ToString().ToLower().Trim() == txtTenDichVu.Text.ToString().Trim()
                if (i != iRowIndex)
                {
                    DataRow drpt = gvDichVu.GetDataRow(i);
                    if (drpt["TenDichVu"].ToString().ToUpper().Trim() == txtTenDichVu.Text.ToString().ToUpper().Trim())
                    {

                        //XtraMessageBox.Show("Trùng tên dịch vụ");
                        dxErrorProvider1.SetError(txtTenDichVu, "Trùng tên dịch vụ");
                        txtTenDichVu.Focus();
                        bCheckValue = false;
                    }
                    else
                        if (txtTenDichVu.Text.ToString() == "")
                        {
                            break;
                        }
                }
                
            }
            
            return bCheckValue;
        }

        private void gvDichVu_DoubleClick(object sender, EventArgs e)
        {

            gdDichVu.Focus();
            DataRow drdv = gvDichVu.GetDataRow(gvDichVu.FocusedRowHandle);

            txtDichVuCode.Text = drdv["dvucode"].ToString().Trim();
            txtTenDichVu.Text = drdv["TenDichVu"].ToString().Trim();
            txtGia.Text = drdv["fee"].ToString().Trim();
            gdLoaiDichVu.EditValue = drdv["loaidvu"].ToString();
            txtMaBHYT.Text = drdv["MaBHYT"].ToString().Trim();
            txtGiaBHYT.Text = drdv["giabhyt"].ToString().Trim();
            chkNhomDV.EditValue = drdv["nhomdvu"].ToString();
            gdPhanLoaiDV.EditValue = drdv["loaidvu1"].ToString();
            gdNhomVSGPB.EditValue = drdv["IDNhomVSGPB"].ToString();
            gdNoiGui.EditValue = drdv["IDNoiGuiDichVu"].ToString();
            chkGuiDi.Checked = Uit.it_Parse.ToBoolean(drdv["guidi"].ToString());
            chkStop.Checked = Uit.it_Parse.ToBoolean(drdv["stopsd"].ToString());
            chkNhomDV.RefreshEditValue();
        }

        #endregion

        #region "Validation"

        void m_setNullValue()
        {
            txtDichVuCode.Text = "";
            txtTenDichVu.Text = "";
            txtGia.Text = "";
            gdLoaiDichVu.EditValue = -1;
            txtMaBHYT.Text = "";
            txtGiaBHYT.Text = "";
            for (int i = 0; i < chkNhomDV.Properties.Items.Count; i++)
            {
                chkNhomDV.Properties.Items[i].CheckState = CheckState.Unchecked;
            }
            gdPhanLoaiDV.EditValue = -1;
            gdNhomVSGPB.EditValue = -1;
            gdNoiGui.EditValue = -1;
            chkGuiDi.Checked = false;
            chkStop.Checked = false;
        }

        void m_setReadOnly()
        {
            txtDichVuCode.Properties.ReadOnly = true;
            txtTenDichVu.Properties.ReadOnly = true;
            txtGia.Properties.ReadOnly = true;
            gdLoaiDichVu.Properties.ReadOnly = true;
            txtMaBHYT.Properties.ReadOnly = true;
            txtGiaBHYT.Properties.ReadOnly = true;
            chkNhomDV.Properties.ReadOnly = true;
            gdPhanLoaiDV.Properties.ReadOnly = true;
            gdNhomVSGPB.Properties.ReadOnly = true;
            gdNoiGui.Properties.ReadOnly = true;
            chkGuiDi.Properties.ReadOnly = true;
            chkStop.Properties.ReadOnly = true;
        }

        void m_setReadOnlyFalse()
        {
            txtDichVuCode.Properties.ReadOnly = false;
            txtTenDichVu.Properties.ReadOnly = false;
            txtGia.Properties.ReadOnly = false;
            gdLoaiDichVu.Properties.ReadOnly = false;
            txtMaBHYT.Properties.ReadOnly = false;
            txtGiaBHYT.Properties.ReadOnly = false;
            chkNhomDV.Properties.ReadOnly = false;
            gdPhanLoaiDV.Properties.ReadOnly = false;
            gdNhomVSGPB.Properties.ReadOnly = false;
            gdNoiGui.Properties.ReadOnly = false;
            chkGuiDi.Properties.ReadOnly = false;
            chkStop.Properties.ReadOnly = false;
        }

        #endregion

        private void btnInsert_Click(object sender, EventArgs e)
        {
            m_Status = DatasetStatus.Add;

            btnSave.Enabled = true;
            btnInsert.Enabled = false;
            m_setReadOnlyFalse();
            m_setNullValue();

            //reset load du lieu----------------------
            gvDichVu.ActiveFilterEnabled = false;
            gvDichVu.ClearColumnsFilter();
            gvDichVu.OptionsFilter.Reset();
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            m_Status = DatasetStatus.Edit;

            btnSave.Enabled = true;
            btnInsert.Enabled = true;
            btnUpdate.Enabled = false;
            m_setReadOnlyFalse();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            btnInsert.Enabled = true;
            btnSave.Enabled = false;
            m_setNullValue();
            m_setReadOnly();
            DataTable dtloadDV = dichVuCtl.m_SelectAllDV();
            gdDichVu.DataSource = dtloadDV;

            //reset load du lieu----------------------
            gvDichVu.ActiveFilterEnabled = false;
            gvDichVu.ClearColumnsFilter();
            gvDichVu.OptionsFilter.Reset();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            DataRow drdv = gvDichVu.GetDataRow(gvDichVu.FocusedRowHandle);
            if (drdv != null)
            {
                dichVuDto.Idvuid = Uit.it_Parse.ToInteger(drdv["dvuid"].ToString());
                dichVuCtl.m_DeleteDichVu(dichVuDto);

                //load danh sach PT
                DataTable dtloadDV = dichVuCtl.m_SelectAllDV();
                gdDichVu.DataSource = dtloadDV;
            }

            m_setNullValue();
            XtraMessageBox.Show("Xóa thành công");

            //reset load du lieu----------------------
            gvDichVu.ActiveFilterEnabled = false;
            gvDichVu.ClearColumnsFilter();
            gvDichVu.OptionsFilter.Reset();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (m_CheckSave() == true)
            {
                dichVuDto.Sdvucode = txtDichVuCode.Text.ToString().Trim();
                dichVuDto.STenDichVu = txtTenDichVu.Text.ToString().Trim();
                dichVuDto.Stendvu = Uit.it_Font.UnicodeToVNI(txtTenDichVu.Text.ToString().Trim());
                dichVuDto.Ifee = Uit.it_Parse.ToInteger(txtGia.Text.Trim());
                dichVuDto.Sloaidvu = gdLoaiDichVu.EditValue.ToString();
                dichVuDto.SMaBHYT = txtMaBHYT.Text.ToString().Trim();
                dichVuDto.Igiabhyt = Uit.it_Parse.ToInteger(txtGiaBHYT.Text.ToString().Trim());
                dichVuDto.Snhomdvu = chkNhomDV.EditValue.ToString();
                dichVuDto.Sloaidvu1 = gdPhanLoaiDV.EditValue.ToString();
                dichVuDto.IIDNhomVSGPB = Uit.it_Parse.ToInteger(gdNhomVSGPB.EditValue.ToString());
                dichVuDto.IIDNoiGuiDichVu = Uit.it_Parse.ToInteger(gdNoiGui.EditValue.ToString());
                dichVuDto.Bguidi = Uit.it_Parse.ToBoolean(chkGuiDi.Checked);
                dichVuDto.Bstopsd = Uit.it_Parse.ToBoolean(chkStop.Checked);

                DataRow dr = gvDichVu.GetDataRow(gvDichVu.FocusedRowHandle);
                if (m_Status == DatasetStatus.Add)
                {
                    dichVuCtl.m_InsertDichVu(dichVuDto);
                    XtraMessageBox.Show("Thêm dịch vụ thành công");
                }
                else
                {
                    if (m_Status == DatasetStatus.Edit)
                    {
                        dichVuDto.Idvuid = Uit.it_Parse.ToInteger(dr["dvuid"].ToString());
                        dichVuCtl.m_UpdateDichVu(dichVuDto);
                        XtraMessageBox.Show("Cập nhật thành công");
                    }
                }
                //m_setNullValue();
            }
            else
            {
                XtraMessageBox.Show("Phải hoàn thành thông tin");
                return;
            }
            //XtraMessageBox.Show("Hoàn thành thông tin");
            //load danh sach PT
            DataTable dtloadDV = dichVuCtl.m_SelectAllDV();
            gdDichVu.DataSource = dtloadDV;

            btnSave.Enabled = false;
            btnUpdate.Enabled = true;
            btnInsert.Enabled = true;
            m_setReadOnly();
            m_setNullValue();
        }

        //click focus row in gridcontrol and then, load data row up textbox----------------
        private void gvDichVu_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            iRowIndex = e.FocusedRowHandle;

            txtDichVuCode.EditValue = (sender as GridView).GetFocusedRowCellValue("dvucode");
            txtTenDichVu.EditValue = (sender as GridView).GetFocusedRowCellValue("TenDichVu");
            txtGia.EditValue = (sender as GridView).GetFocusedRowCellValue("fee");
            gdLoaiDichVu.EditValue = (sender as GridView).GetFocusedRowCellValue("loaidvu");
            txtMaBHYT.EditValue = (sender as GridView).GetFocusedRowCellValue("MaBHYT");
            txtGiaBHYT.EditValue = (sender as GridView).GetFocusedRowCellValue("giabhyt");
            chkNhomDV.EditValue = (sender as GridView).GetFocusedRowCellValue("nhomdvu");
            gdPhanLoaiDV.EditValue = (sender as GridView).GetFocusedRowCellValue("loaidvu1");
            gdNhomVSGPB.EditValue = (sender as GridView).GetFocusedRowCellValue("IDNhomVSGPB");
            gdNoiGui.EditValue = (sender as GridView).GetFocusedRowCellValue("IDNoiGuiDichVu");
            chkGuiDi.EditValue = (sender as GridView).GetFocusedRowCellValue("guidi");
            chkStop.EditValue = (sender as GridView).GetFocusedRowCellValue("stopsd");
        }



      

    }
}